home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 10.6 KB | 308 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWUtil.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWSESION_H
- #include "FWSesion.h"
- #endif
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef SOM_Module_OpenDoc_Errors_defined
- #include <ErrorDef.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment framework
- #endif
-
- //========================================================================================
- // utilities
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_IsInLimbo
- //----------------------------------------------------------------------------------------
- // [HLX] I have to put a try block because of a bug in OpenDoc 1.0
-
- FW_Boolean FW_IsInLimbo(Environment* ev, ODFrame* frame)
- {
- FW_Boolean result = FALSE;
- FW_TRY
- {
- result = frame->IsInLimbo(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING ()
- {
- if (FW_GetEvError(ev) != kODErrInvalidFrame)
- FW_THROW_SAME ();
- }
- FW_CATCH_END
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_ReadODValueTypeFromStream
- //----------------------------------------------------------------------------------------
-
- ODValueType FW_ReadODValueTypeFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- FW_UNUSED(ev);
- ODValueType typeValue;
-
- FW_CString aStr;
- stream >> aStr;
-
- FW_ByteCount byteCount = aStr.GetByteLength();
- typeValue = (char*)FW_CMemoryManager::AllocateBlock(byteCount + 1);
- FW_CMemoryManager::CopyMemory(aStr.RevealBuffer(), typeValue, byteCount);
- typeValue[byteCount] = 0;
-
- return typeValue;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_ReadODTypeTokenFromStream
- //----------------------------------------------------------------------------------------
-
- ODTypeToken FW_ReadODTypeTokenFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- ODValueType viewTypeValue = FW_ReadODValueTypeFromStream(ev, stream);
- ODTypeToken token = FW_CSession::Tokenize(ev, viewTypeValue);
- FW_CMemoryManager::FreeBlock(viewTypeValue);
- return token;
- }
-
- //========================================================================================
- // Content to Frame and Frame to Content coordinate conversions
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_ContentToFrame
- //----------------------------------------------------------------------------------------
-
- void FW_ContentToFrame(Environment* ev, ODFrame* frame, ODShape* shape)
- {
- FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
- shape->Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_FrameToContent
- //----------------------------------------------------------------------------------------
-
- void FW_FrameToContent(Environment* ev, ODFrame* frame, ODShape* shape)
- {
- FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
- shape->InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_ContentToFrame
- //----------------------------------------------------------------------------------------
-
- void FW_ContentToFrame(Environment* ev, ODFrame* frame, FW_CPoint& point)
- {
- FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
- point.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_FrameToContent
- //----------------------------------------------------------------------------------------
-
- void FW_FrameToContent(Environment* ev, ODFrame* frame, FW_CPoint& point)
- {
- FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
- point.InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_ContentToFrame
- //----------------------------------------------------------------------------------------
-
- void FW_ContentToFrame(Environment* ev, ODFrame* frame, FW_CRect& rect)
- {
- FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
- rect.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_FrameToContent
- //----------------------------------------------------------------------------------------
-
- void FW_FrameToContent(Environment* ev, ODFrame* frame, FW_CRect& rect)
- {
- FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
- rect.InverseTransform(ev, transform);
- }
-
- //========================================================================================
- // Content to Window and Window to Content coordinate conversions
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_ContentToWindow
- //----------------------------------------------------------------------------------------
-
- void FW_ContentToWindow(Environment* ev, ODFacet* facet, ODShape* shape)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
- shape->Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_WindowToContent
- //----------------------------------------------------------------------------------------
-
- void FW_WindowToContent(Environment* ev, ODFacet* facet, ODShape* shape)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
- shape->InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_ContentToWindow
- //----------------------------------------------------------------------------------------
-
- void FW_ContentToWindow(Environment* ev, ODFacet* facet, FW_CPoint& point)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
- point.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_WindowToContent
- //----------------------------------------------------------------------------------------
-
- void FW_WindowToContent(Environment* ev, ODFacet* facet, FW_CPoint& point)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
- point.InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_ContentToWindow
- //----------------------------------------------------------------------------------------
-
- void FW_ContentToWindow(Environment* ev, ODFacet* facet, FW_CRect& rect)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
- rect.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_WindowToContent
- //----------------------------------------------------------------------------------------
-
- void FW_WindowToContent(Environment* ev, ODFacet* facet, FW_CRect& rect)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
- rect.InverseTransform(ev, transform);
- }
-
- //========================================================================================
- // Frame to Window and Window to Frame coordinate conversions
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_FrameToWindow
- //----------------------------------------------------------------------------------------
-
- void FW_FrameToWindow(Environment* ev, ODFacet* facet, ODShape* shape)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
- shape->Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_WindowToFrame
- //----------------------------------------------------------------------------------------
-
- void FW_WindowToFrame(Environment* ev, ODFacet* facet, ODShape* shape)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
- shape->InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_FrameToWindow
- //----------------------------------------------------------------------------------------
-
- void FW_FrameToWindow(Environment* ev, ODFacet* facet, FW_CPoint& point)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
- point.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_WindowToFrame
- //----------------------------------------------------------------------------------------
-
- void FW_WindowToFrame(Environment* ev, ODFacet* facet, FW_CPoint& point)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
- point.InverseTransform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_FrameToWindow
- //----------------------------------------------------------------------------------------
-
- void FW_FrameToWindow(Environment* ev, ODFacet* facet, FW_CRect& rect)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
- rect.Transform(ev, transform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_WindowToFrame
- //----------------------------------------------------------------------------------------
-
- void FW_WindowToFrame(Environment* ev, ODFacet* facet, FW_CRect& rect)
- {
- FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
- rect.InverseTransform(ev, transform);
- }
-
-
-